package active.iterators;

import constructor.composite.Deparment;

import java.util.Iterator;

public class ComputerCollegeIterator implements Iterator {

    Deparment[] deparments;
    int posi = 0;

    public ComputerCollegeIterator(Deparment[] deparments) {
        this.deparments = deparments;
    }

    @Override
    public boolean hasNext() {
        if (posi >= deparments.length || deparments[posi] == null) {
            return false;
        }
        return true;
    }

    @Override
    public Object next() {
        Deparment deparment = deparments[posi];
        posi++;
        return deparment;
    }

    @Override
    public void remove() {
        Iterator.super.remove();
    }
}
